home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group96a.txt
/
000030_icon-group-sender _Mon Jan 29 10:05:18 1996.msg
< prev
next >
Wrap
Internet Message Format
|
1996-09-05
|
4KB
Received: by cheltenham.cs.arizona.edu; Mon, 29 Jan 1996 12:22:42 MST
Date: Mon, 29 Jan 1996 10:05:18 -0600 (CST)
From: "Chris D. Tenaglia" <cdt@post.its.mcw.edu>
To: Budi Rahardjo <rahardj@cc.umanitoba.ca>
Cc: icon-group@cs.arizona.edu
Subject: Re: processing utmp and/or wtmp with icon
In-Reply-To: <slrn4gnrln.dpt.rahardj@phad.cc.umanitoba.ca>
Message-Id: <Pine.ULT.3.90.960129100045.21685A-100000@post.its.mcw.edu>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Errors-To: icon-group-errors@cs.arizona.edu
Status: O
Here's a quick sample of my approach. It worked on solaris, but
may need adjustments elsewhere. I did a man utmp to get the record
layout. Anyway, the basic approach is:
########################### begin program #######################
# file : get_utmp.icn
# desc : reads /etc/utmp and outputs ascii lines
# use : get_utmp [>outfile]
# warn : Worked on solaris, others? I don't know. Needs calc_date() finished
# to convert date to readable form. AS IS. NO WARANTY.
#
# update by what
# 29-jan-1996 tenaglia initial write
#
procedure main()
ut_table := table("Unknown")
ut_table[0] := "EMPTY"
ut_table[1] := "RUN_LVL"
ut_table[2] := "BOOT_TIME"
ut_table[3] := "OLD_TIME"
ut_table[4] := "NEW_TIME"
ut_table[5] := "INIT_PROCESS"
ut_table[6] := "LOGIN_PROCESS"
ut_table[7] := "DEAD_PROCESS"
ut_table[8] := "ACCOUNTING"
in := open("/etc/utmp","u")
while entry := reads(in,36) do
{
entry ? {
user := map(move(8),"\0"," ")
utab := map(move(4),"\0"," ")
utli := map(move(12),"\0"," ")
pid := move(2)
utyp := move(2)
tsta := move(2)
esta := move(2)
utim := move(4)
}
pid := right(decimal(pid),6)
ut_type := left(ut_table[decimal(utyp)],16)
tstatus := right(decimal(tsta),4)
estatus := right(decimal(esta),4)
timus := calc_date(decimal(utim))
write(user," ",utab," ",utli," ",pid," ",ut_type," ",tstatus," ",estatus," ",timus)
}
close(in)
end
#
# determine the value of a raw hex number
#
procedure decimal(raw)
begin := 0
total := 0
every i := *raw to 1 by -1 do
{
value := ord(raw[i])
total+:= value * (256^begin)
begin+:= 1
}
return total
end
#
# calculate date based from seconds after 1970
# needs to be completed.
#
procedure calc_date(value)
static leaps,spy,sply,cury
initial {
leaps := set([1972,1976,1980,1984,1988,1992,1996,2000,2004])
spy := 31536000
sply := 31622400
cury := &date[1+:4]
}
if 0 > value > 1000000000 then return "Out of range"
yr := 1970
return value
repeat
{
}
end
#################### END CODE ###############################
Chris Tenaglia (system manager) | cdt@post.its.mcw.edu
Medical College of Wisconsin |
8701 W. Watertown Plank Rd. | Ce que vous voyez est
Milwaukee, WI 53226 (414)456-8765 | ce que vous obtenez !
On 28 Jan 1996, Budi Rahardjo wrote:
> Date: 28 Jan 1996 21:46:33 GMT
> From: Budi Rahardjo <rahardj@cc.umanitoba.ca>
> To: icon-group@cs.arizona.edu
> Subject: processing utmp and/or wtmp with icon
>
> We are planning to write a program which converts utmp/wtmp file
> into somekind of database (delimitted, flat file would be good enough).
> The database is used to produces statistics such as usage, number of logins,
> how many hours one has logged in to a system this month, etc.
> We want to produce this stats in real time too.
>
> Actually, I have written this in perl but wanted to make it an executable.
> Icon seems to be a natural approach ( don't want to go to C or C++).
> Before I start rolling the design, has anybody done this?
> Any tips.
>
> Thanks
> -- budi
> --
> Budi Rahardjo <Budi_Rahardjo@UManitoba.Ca>
> #include <std-disclaimer.h>
>
>